<?php
$jsonval="";

if(isset($_POST["X_ID"]) && is_numeric($_POST["X_ID"]) && isset($_POST["X_UPLOADER"])){
    $UploaderID=trim($_POST["X_UPLOADER"]);
    $UploadPostId=trim($_POST["X_ID"]);
    
    if(isset($_FILES) && trim($_FILES["userfile"]["error"])==0 ){
        $arr = array('errCode' => 200, 'postId' => $UploadPostId, 'uploaderID' => $UploaderID, 'uploadPath' => $_FILES["userfile"]["tmp_name"], 'msg' => 'uploaded successfully');
        //$jsonval.="{\"name\":\"".$_FILES["userfile"]["name"]."\",\"type\":\"".str_replace("\\","\/",$_FILES["userfile"]["type"]."\",\"tmp_name\":\"".$_FILES["userfile"]["tmp_name"])."\",\"size\":\"".$_FILES["userfile"]["size"]."\"}";    
    }
    else{
        $arr = array('errCode' => 400, 'postId' => $UploadPostId, 'uploaderID' => $UploaderID, 'uploadPath' => '', 'msg' => 'some error occurred'.$_FILES["userfile"]["error"]);
    }
    
}
$arr = array('errCode' => 500, 'postId' => -1, 'uploaderID' => -1, 'uploadPath' => '', 'msg' => 'arguments missing or invalid request');
echo json_encode($arr);
?>